package com.catsic.mod.dao;

import org.springframework.data.jpa.repository.Query;

import com.catsic.base.BaseDao;
import com.catsic.mod.entity.ReceiveMessage;
import com.catsic.core.entity.User;

public interface ReceiveMessageDao  extends BaseDao<ReceiveMessage,String>{
	/**
	 * 查询未读邮件数
	 * @param user
	 * @return
	 */
	@Query("select count(r.id) from ReceiveMessage r where r.id not in (select s.messageId from ReadMessage s) and r.addresseeId = ?1 and r.remind = 'yes'")
	public Integer findCountById(String userId);
	
	@Query("select organ.name from Organ organ where organ.id = ?1")
	public String findOrganById(String organId);
	
	@Query("select user from User user where user.id = ?1")
	public User findRoleById(String userId);
}
